{% extends "bvblogapp/base.html" %}

{% block pageName %}BioVenturist - Search medical conditions{% endblock %}

{% block queryScript %}


<!--================================================== -->
<!-- Combo-handled YUI CSS files: -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.8.0r4/build/paginator/assets/skins/sam/paginator.css&2.8.0r4/build/datatable/assets/skins/sam/datatable.css">
<!-- Combo-handled YUI JS files: -->
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.8.0r4/build/utilities/utilities.js&2.8.0r4/build/datasource/datasource-min.js&2.8.0r4/build/paginator/paginator-min.js&2.8.0r4/build/datatable/datatable-min.js&2.8.0r4/build/json/json-min.js&2.8.0r4/build/selector/selector-min.js"></script>
<!-- Page style -->
<link type="text/css" rel="stylesheet" href="/bvsearchapp/static/css/bvsearchapp.css" />
<!-- jQuery packed from Google CDN -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/jquery.livequery.js"></script>
<!--script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script-->
<!-- Freebase suggest -->
<link type="text/css" rel="stylesheet" href="/static/css/freebase-controls.css" />
<script src="/static/js/freebase.suggest.js" type="text/javascript"></script>
<!-- Curvy corners jQuery plugin -->
<script type="text/javascript" src="/static/js/jquery.curvycorners.packed.js"></script>
<!-- Facebox jQuery plugin -->
<link href="/bvsearchapp/static/js/facebox.css" media="screen" rel="stylesheet" type="text/css"/>
<script src="/bvsearchapp/static/js/facebox.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
    $('.c').corner();
});
</script>
<!-- Load ListFormatter and CompanyNameFormatter -->
<script type="text/javascript" src="/bvsearchapp/static/js/formatters.js"></script>
<script type="text/javascript">function load_info(){return true}</script>
<!--================================================== -->

<script type="text/javascript">
/*global ListFormatter: false, CompanyNameFormatter: false, YAHOO: false */
/* Settings */

var RECORDS_PER_PAGE = 5; // Set the count of records per page
var BIOVENTURIST_DIR = '/base/bioventurist/';

/* begin: type_for_freebase_suggest - Return freebase type for specified filter */
var type_for_freebase_suggest = function (t) {
    var TYPES_FOR_FREEBASE_SUGGEST = {
        'name': BIOVENTURIST_DIR + 'bv_medical_condition',
        'has_company_involved': BIOVENTURIST_DIR + 'science_or_technology_company',
        'has_therapeutics': BIOVENTURIST_DIR + 'indication'
    };
    return TYPES_FOR_FREEBASE_SUGGEST[t];
};
/* end: type_for_freebase_suggest */

var not_default_columns = [{
    key: 'key',
    label: 'Database keys',
    formatter: ListFormatter
}
];

var ResultsColumnDefs = [{
    key: 'name',
    label: 'Medical condition',
    width: 150
},
{
    key: 'has_company_involved',
    label: 'Company Involved',
    formatter: ListFormatter,
    sortable: true
},
{
    key: 'has_therapeutics',
    label: 'Therapeutics',
    formatter: ListFormatter,
    sortable: true
},
{
    key: 'has__medicine_disease_causes',
    label: 'Causes',
    formatter: ListFormatter,
    sortable: true
},
{
    key: 'has__medicine_disease_includes_diseases',
    label: 'Includes Diseases',
    formatter: ListFormatter,
    sortable: true
}
];

var Results = new YAHOO.util.XHRDataSource('{% url medical_conditions_search_ajax "json" %}');
Results.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
Results.responseSchema = {
    resultsList: 'Results',
    fields: [{
        key: 'name'
    },
    {
        key: 'has_company_involved'
    },
    {
        key: 'has_therapeutics'
    },
    {
        key: 'has__medicine_disease_causes'
    },
    {
        key: 'has__medicine_disease_includes_diseases'
    }
    ]
};

var emptyMessage = 'Please enter a query above to find information about medical conditions';
</script>

<script type="text/javascript" src="/bvsearchapp/static/js/companies_ie.datatable.js"></script>
<script type="text/javascript" src="/bvsearchapp/static/js/companies_ie.filter.js"></script>
<script type="text/javascript" src="/bvsearchapp/static/js/companies_ie.select_list.js"></script>
<script type="text/javascript" src="/bvsearchapp/static/js/companies_ie.yuitable.js"></script>
<script type="text/javascript" src="/bvsearchapp/static/js/companies_ie.actions.js"></script>

<script type="text/javascript">
/*global jQuery: false, location: false, document: false, requestBuilder: false */
jQuery(document).ready(function () {
    /* When user clicks on 'Export' button */
    jQuery('#id_button_export').click(function () {
        var loc = '{% url technologies_search_ajax "csv" %}' + requestBuilder();
        location.href = loc;
    });

    /* When user clicks on 'Share' button */
    jQuery('#id_share_button').click(function () {
        jQuery.facebox('<p style="font-size: 1.2em">Copy following link to share the page:<br/><code>' + location.protocol + '//' + location.host + '/search/technologies/' + requestBuilder() + '</code></p>');
    });
});
</script>
{% endblock %}

{% block container %}
<div id="bvsearchapp">

<!-- begin: Search block -->
<div class="container" style="width:889px;">
    <div class="c" style="background:#F1F1F1;padding:16px; border: 2px solid #999;">
        <div id="filters_div">
            <span class="large">Find medical conditions by</span>
            <select name="filter_type" class="first filter_type">
                <option value="name">Medical condition</option>
                <option value="has_company_involved">Companies involved</option>

            </select>
            <input type="text" size="10" name="filter_query" class="filter_query" />
            <input type="button" class="filter_add" value="+"/>
            <input type="button" class="filter_run" name="filter" value="Search" />
            <img src="/static/img/ajax-loader.gif" style="margin-left: .5em; display: none; position: relative; top: 3px;" id="img_loading" alt="Loading..." /><br />
        </div>
    </div>
</div>
<!-- end: Search block -->

<!-- begin: Count of results -->
<p class="results_count">Showing <span id="records_index"></span> <strong id="total_records">0</strong> medical conditions <span id="filters"></span></p>
<!-- end: Count of results -->

<div class="w100p" style="margin-bottom: 1em;">
    <table border="0" cellpadding="0" cellspacing="0" valign="middle" style="width: 100%; margin-top: 1em;">
        <tr>
            <td width="50%">
                <a id="id_add_rows" class="u" href="#">Add</a>
                <select id="id_row_to_add" name="row_to_add" style="display: none;"></select>
                <input type="button" name="button_row_add" id="id_button_row_add" value="Add"  style="display: none;"/>
                <span> or </span>
                <a id="id_rm_rows" class="u" href="#">Del</a>
                <select id="id_row_to_rm" name="row_to_rm" style="display: none;"></select>
                <input type="button" name="button_row_rm" id="id_button_row_rm" value="Del"  style="display: none;"/>
                <span> columns?</span>
            </td>
            <td width="50%" class="right">
                <input type="button" name="save" value="Save {% if not request.user.username %}*{% endif %}" id="id_button_save" {% if not request.user.username %}disabled{% endif %}/>
                <input type="button" id="id_share_button" name="share" value="Share" />
                <input type="button" name="export" value="Export" id="id_button_export"/>
                {% if not request.user.username %}
                <p style="font-size: x-small; color: #999; text-align: right;">* You must  be logged in.</p>
                {% endif %}
           </td>
        </tr>
    </table>
</div>

<div id="results"></div>
<div id="paginated"></div>

<form name="widget" id="widget" method="POST" style="display: none;" action="{% url companies_widget %}">
    <textarea name="text" id="input_widget" rows="30" cols="100"></textarea>
</form>

{% if request.user.username %}
<form name="save_as_analysis" id="post_to_analysis" method="POST" style="display: none;" action="{% url blog_create request.user.username %}">
    <textarea name="text" id="text" rows="30" cols="100"></textarea>
    <input type="hidden" name="external_data" value="True" /> <!-- If this variable in POST, then new analysis will be filled with POST['text'] data. -->
</form>
{% endif %}

<div class="right w100p top_margin_1em">

</div>




{% endblock %}
